You should know about
Using the Console!
Aliases
You define blocks of actions by defining an alias for them.
//old style:
alias aNAME $aVALUE
//new style:
aNAME = $aVALUE
A common cause for errors is forgetting spaces around the "="-sign in the new style!
In both variants the "$aVALUE" represents any valid CubeScript block.
Examples:
my_value = 0
bind KP_5 [my_value = 5; onrelease my_value = 1]
my_script = [if (= @my_value 1) [echo yes] [echo my value is @@my_value]]
param_script = [
if (= $arg 1) [
echo "yes :" @arg2 @arg3 @arg4
] [
echo "no :" @arg1
]
]
param_script 0 1 2 3
param_script 1 2 3 4
param_script 1
param_script 4 3 2 1
param_script 1
Keybindings
Beware of binding keys that are already bound by the default configuration - unless you're sure you know what you're doing :)
Check data/defaults.cfg for this.
Triggering Action
For SP maps you can have
trigger entities do scripting commands whenever the player touches the entity.
The basic concept is to create aliases like
level_trigger_123 = [echo you triggered #123]
This would be executed when the player crosses the space of any trigger-entity with first param 123.
Triggers
Sauerbraten can trigger special
scripting for you,
when an SP player crosses the space of one of your trigger entities;
triggers only work in SP (singleplayer mode), not MP (multiplayer mode)!
Historical development associates a
carrot model with triggers,
but any mapmodel can be used.
Each trigger has it's index - entproperty 0.
You may have multiple entities with the same index though.
Triggering another trigger will
not always do exactly what you want ATM,
development toward that angle is under way!
Maybe an example would be more educational?
Look at this
MapTriggerTest.zip [6.7K]
map and it's cfg to see how to implement a basic
secret's counter.
There is also a secret's counter in "Episode 1" and other maps contain other scripting that you might like to use.
You should also check out stuff you liked in somebody else's map and in their cfg to work out how they did it.
To see how to trigger doors look at the map "door_demo" included with sauerbraten.